//
//  Macro.swift
//  SwiftDemo
//
//  Created by Steven on 2020/8/3.
//  Copyright © 2020 Steven. All rights reserved.
//

import Foundation
import UIKit


@_exported import RxSwift
@_exported import RxCocoa
@_exported import HandyJSON
@_exported import  Kingfisher
@_exported import Toast_Swift
@_exported import SnapKit


let kDate_Location = "zh_CN"
let kTabbarHeight = 49
let kNabBarHeight = 44
let kLineHeight = 0.5
let kSectionHeight:CGFloat = 48
let kMarginHeight = 8
let kLimitPhone = 11
let kLimitPassword = 16
let kLimitSecurityCode = 4
let kScreenHeight:CGFloat = UIScreen.main.bounds.height
let kScreenWidth:CGFloat = UIScreen.main.bounds.width
let kSafeAreaBottomH:CGFloat = ((kScreenHeight == 812.0) || (kScreenHeight == 896.0)) ? 34 : 0
let kSafeAreaTopH:CGFloat = ((kScreenHeight == 812.0) || (kScreenHeight == 896.0)) ? 88 : 64
let kSystemVersion = (UIDevice.current.systemVersion as NSString).floatValue
let kStatusBarHeight = UIApplication.shared.statusBarFrame.height
let kMainScreenScal = UIScreen.main.scale
let kNavigationHeight =  (CGFloat(kStatusBarHeight) + CGFloat(kNabBarHeight))
let kUserDefaults = UserDefaults.standard
let kNotife = NotificationCenter.default
let kAppVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")
let kUUID =  UIDevice.current.identifierForVendor?.uuidString.replacingOccurrences(of: "-", with: "")

//获取命名空间 在info.plist文件里就是Executable file
let nameSpace = Bundle.main.infoDictionary!["CFBundleExecutable"] as! String

//拼接成固定格式
func STClassFromString(name:String) -> AnyClass {
    return NSClassFromString(nameSpace + "." + name)!
}

//文件夹路径
struct kDirectoryPath {
    static let Documents = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last
    static let Library = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true).last
    static let Tmp = NSTemporaryDirectory()
    static let Caches = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).last
}

func DLog<T>(_ message : T, file : String = #file, function:String = #function, lineNumber:Int = #line){
    #if DEBUG
    let fileName = (file as NSString).lastPathComponent
    let funtionStr = function.split(separator: "(").first
    print("\n**************自定义日志输出:*************\n\(fileName):\(funtionStr ?? "")():[\(lineNumber)]\n\(message)\n**************")
    #endif
}

func kImage(name:String) -> UIImage?{
    return UIImage(named: name)
}

func kFont(size:CGFloat) -> UIFont{
    return UIFont.systemFont(ofSize: size)
}
   
func kRGBCOLOR(r:CGFloat,g:CGFloat,b:CGFloat) -> UIColor{
   return UIColor(red:  r/255.0, green: g/255.0, blue:  b/255.0, alpha: 1)
}

func kRGBACOLOR(r:CGFloat,g:CGFloat,b:CGFloat, a:CGFloat) -> UIColor{
    return UIColor(red:  r/255.0, green: g/255.0, blue:  b/255.0, alpha: a)
}

//RGB 16进制转换
func KRGBHEXCOLOR(rgbValue: UInt) -> UIColor {
    return UIColor(
        red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
        green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
        blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
        alpha: CGFloat(1.0)
    )
}




 let KViewBackgroundColor = KRGBHEXCOLOR(rgbValue:0xf7f7f7)  // f5f5f5
 let KFont_goldenColor = KRGBHEXCOLOR(rgbValue:0xd2aa60)
 let KStatusBarColor    =  kRGBCOLOR(r:0,g:11,b:15)
 let KFont_redColor = KRGBHEXCOLOR(rgbValue:0xff6c6c)
 let KLineColor  = KRGBHEXCOLOR(rgbValue:0xe7e8ed)
 let KFont_blackColor  = KRGBHEXCOLOR(rgbValue:0x3a404c)
 let KFont_blueColor =  KRGBHEXCOLOR(rgbValue:0x3b9afe)
 let KFont_grayColor  = KRGBHEXCOLOR(rgbValue:0x92969f)
 let KFont_textFieldColor =  KRGBHEXCOLOR(rgbValue:0xb9bdc6)
